package com.diaohw.module.file.obj.convert;

import com.diaohw.module.file.obj.dto.AccountFileDTO;
import com.diaohw.module.file.obj.entity.AccountFileDO;
import com.diaohw.module.file.obj.vo.AccountFileVO;
import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * <p>
 * 用户上传表 类型转换
 * </p>
 *
 * @author D-Hw
 * @since 2024-11-05
 */
@Mapper
public interface AccountFileConvert {

    AccountFileConvert INSTANCE = Mappers.getMapper(AccountFileConvert.class);

    /**
     * dto to entity
     */
    @InheritConfiguration
    AccountFileDO dtoToEntity(AccountFileDTO dto);

    /**
     * entity to dto
     */
    @InheritConfiguration
    AccountFileDTO entityToDto(AccountFileDO entity);

    /**
     * entity to dto
     */
    @InheritConfiguration
    @Mappings({
            @Mapping(target = "tags", ignore = true),
            @Mapping(source = "createdBy", target = "updateUser"),
            @Mapping(source = "createdTime", target = "uploadTime")
    })
    AccountFileVO entityToVo(AccountFileDO entity);

    /**
     * entity to dto
     */
    @InheritConfiguration
    @Mappings({
            @Mapping(target = "tags", ignore = true),
            @Mapping(source = "createdBy", target = "updateUser"),
            @Mapping(source = "createdTime", target = "uploadTime")
    })
    List<AccountFileVO> entityToVo(List<AccountFileDO> list);


}

